"use client";
import { UserInfoRep, UserVipInfo, Wallet } from "@/api/user";
import TipsModal, { ModalProps } from "@/components/TipsModal";
import { Link, useRouter } from "@/i18n/routing";
import { WalletEnum } from "@/types";
import { vipImages } from "@/utils/constant";
import { flatPoint, percentage } from "@/utils/methods";
import { ProgressBar, Toast } from "antd-mobile";
import { useTranslations } from "next-intl";
import Image from "next/image";
import { Fragment, useRef, useState } from "react";
type Props = {
userInfo: UserInfoRep;
userMoney: Wallet;
userVip: UserVipInfo;
};
const VipCard = (props: { userVip: UserVipInfo }) => {
const { userVip } = props;
const t = useTranslations("ProfilePage");
// Vip 图标
const vipIconElement = vipImages.map((item, index) => {
if (item.leve === userVip.vip_level) {
return (
{item.leve}
);
}
});
return (
{vipIconElement}
{/*
{userVip.vip_exp}xp
*/}
VIP{userVip.vip_level}
{t("expTips", {
exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp),
})}
VIP
{userVip.vip_next_level}
);
};
const Progress = (props: { percent: number }) => {
const { percent } = props;
return (
);
};
// 现金
const Balance = (props: { wallet: Wallet }) => {
const { wallet } = props;
const num = 1;
const t = useTranslations("ProfilePage");
return (
{t("Saldo")}
{wallet.score}
);
};
const WalletCard = (props: { userMoney: Wallet }) => {
const { userMoney } = props;
const t = useTranslations("ProfilePage");
const [visible, setVisible] = useState(false);
const router = useRouter();
const callbackFun = () => {
setVisible(!visible);
};
const walletHandler = (key: string) => {
router.push(`/${key}`);
};
const tipsRef = useRef(null);
const [tipsStatus, setTipsStatus] = useState("Balance");
return (
<>
{t("modalTitle")}
}
>
{/*现金*/}
{tipsStatus === WalletEnum.Balance ? : null}
{/* 彩金*/}
{/*彩金
*/}
{/* 免费币 */}
{/*免费币
*/}
{/* 重玩币 */}
{/*重玩币
*/}
{t("Saldo")}
brl
{userMoney.score || 0.0}
{t("bonus")}
tipsRef.current?.onOpen()}
width={15}
height={15}
/>
brl
{userMoney.point || 0.0}
walletHandler("free")}>
{t("free")}
{
event.stopPropagation();
setVisible(true);
}}
/>
brl
{userMoney.free_score || 0.0}
walletHandler("replay")}>
{t("replay")}
{
event.stopPropagation();
setVisible(true);
}}
width={15}
height={15}
/>
brl
{userMoney.lose_score || 0.0}
>
);
};
export const ProfileHeader = (props: Props) => {
const { userInfo, userMoney, userVip } = props;
const t = useTranslations("ProfilePage");
const router = useRouter();
const handler = () => {
if (!!userMoney.score) {
router.push("/withdraw");
} else {
Toast.show("no monry");
}
};
return (
<>
{t("Conta")}
{userInfo?.user_phone || ""}
{/*vipcard*/}
{t("Depósito")}
{t("Sacar")}
>
);
};